<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
      xmlns:sec="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <div th:fragment="userValidate">
        <script>
            var rules = {
                live: 'enabled',
                    /* 字段值有变化就触发验证 disabled */
                    /* submitted 当点击提交时验证并展示错误 */
                    message: '信息不合法',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    username: {
                        message: '用户名不合法',
                            validators: {
                            notEmpty: {
                                message: '用户名必须填写,不能为空'
                            },
                            stringLength: {
                                min: 6,
                                    max: 30,
                                    message: '长度必须是6到30个字符'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_\.]+$/,
                                    message: '用户名必须有字母数字下划线组成'
                            }
                        }
                    },
                    tel: {
                        message: '电话不合法',
                            validators: {
                            notEmpty: {
                                message: '电话号码,不能为空'
                            },
                            stringLength: {
                                min: 11,
                                    max: 11,
                                    message: '长度必须是11位'
                            },
                            regexp: {
                                regexp: /^1\d{10}$/,
                                    message: '手机号格式错误'
                            }
                        }
                    },
                    email: {
                        validators: {
                            notEmpty: {
                                message: '邮箱不能空'
                            },
                            emailAddress: {
                                message: '输入邮箱不合格'
                            }
                        }
                    },
                    roleId: {
                        validators: {
                            notEmpty: {
                                message: '角色必须选择'
                            },
                        }
                    },
                    password: {
                        validators: {
                            notEmpty: {
                                message: '密码不能为空'
                            }
                        }
                    },
                    confirmPassword: {
                        validators: {
                            notEmpty: {
                                message: '确认密码不能为空'
                            },
                            identical: {
                                field: 'password',
                                    message: '两次密码不一样哟....'
                            },
                            different: {
                                field: 'username',
                                    message: '密码不能和用户名相同'
                            }
                        }
                    }
                }  /* fields[ END ] */
            };     /* Validate Rules [ END ] */
        </script>
    </div>

    <div id="other">
        <h1>B</h1>
    </div>

</body>
</html>
